package com.fr.report.highlight;

import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.report.CellElement;
import com.fr.report.Report;
import com.fr.report.script.Calculator;

public class ColWidthHighlightAction extends AbstractHighlightAction
{
  private int columnWidth;

  public ColWidthHighlightAction()
  {
  }

  public ColWidthHighlightAction(int paramInt)
  {
    this.columnWidth = paramInt;
  }

  public int getColumnWidth()
  {
    return this.columnWidth;
  }

  public void setColumnWidth(int paramInt)
  {
    this.columnWidth = paramInt;
  }

  public void action(CellElement paramCellElement, Calculator paramCalculator)
  {
    if ((paramCellElement == null) || (paramCalculator == null) || (paramCalculator.getCurrentReport() == null))
      return;
    Report localReport = paramCalculator.getCurrentReport();
    int i = paramCellElement.getColumn();
    int j = i + paramCellElement.getColumnSpan();
    while (i < j)
    {
      localReport.setColumnWidth(i, this.columnWidth);
      ++i;
    }
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if ((paramXMLableReader.isChildNode()) && ("ColumnWidth".equals(paramXMLableReader.getTagName())))
    {
      String str;
      if ((str = paramXMLableReader.getAttr("i")) != null)
        setColumnWidth(Integer.parseInt(str));
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    if (this.columnWidth > 0)
      paramXMLPrintWriter.startTAG("ColumnWidth").attr("i", this.columnWidth).end();
  }
}